package com.alks.function.controller.stockdept.pcfactorystockquery;
/**
 * @author MS
 * @since 2025/6/414:42
 */

import com.alks.entity.data.entity.HgMtl;
import com.alks.entity.data.entity.HgMtlRelation;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.impl.stockdept.pcfactorystockquery.HgMtlServiceImpl;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author MS
 * @since 2025/6/414:42
 */

@RestController
@RequestMapping("/hgMtl")
@Api(value = "仓储部", tags = "海关编码建档")
@Slf4j
@RequiredArgsConstructor
public class HgMtlController {
    @Autowired
    private HgMtlServiceImpl service;

    @GetMapping("/list")
    @ApiOperation(value = "查询", tags = "海关编码建档")
    public ResponseInfo<List<HgMtl>> list(String search) {
        List<HgMtl> list = service.list(search);
        return ResponseInfo.ok(list);
    }

    @PostMapping("/detail/list")
    @ApiOperation(value = "编码下所有物料查询", tags = "海关编码建档")
    public ResponseInfo<Void> detailList(@RequestParam Long id) {
        service.detailList(id);
        return ResponseInfo.ok();
    }

    @PostMapping("/detail/add")
    @ApiOperation(value = "新增关联数据", tags = "海关编码建档")
    public ResponseInfo<Void> detailAdd(@RequestBody HgMtlRelation relation) {
        service.detailAdd(relation);
        return ResponseInfo.ok();
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增", tags = "海关编码建档")
    public ResponseInfo<Void> add(@RequestBody HgMtl hgMtl) {
        service.add(hgMtl);
        return ResponseInfo.ok();
    }

    @PutMapping("/update")
    @ApiOperation(value = "更新", tags = "海关编码建档")
    public ResponseInfo<Void> update(@RequestBody HgMtl hgMtl) {
        service.update(hgMtl);
        return ResponseInfo.ok();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除", tags = "海关编码建档")
    public ResponseInfo<Void> delete(@RequestParam Long id) {
        service.delete(id);
        return ResponseInfo.ok();
    }

}
